package flc.ast.activity;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;

import android.os.Bundle;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;

import java.util.ArrayList;
import java.util.List;

import flc.ast.BaseAc;
import flc.ast.R;
import flc.ast.adapter.DrawTempAdapter;
import flc.ast.bean.MyDrawTempBean;
import flc.ast.databinding.ActivityDrawTempBinding;
import stark.common.basic.event.EventStatProxy;

public class DrawTempActivity extends BaseAc<ActivityDrawTempBinding> {

    private DrawTempAdapter tempAdapter;

    @Override
    protected int onCreate() {
        return R.layout.activity_draw_temp;
    }

    @Override
    protected void initView() {
        EventStatProxy.getInstance().statEvent1(this, mDataBinding.event1Container);

        mDataBinding.ivDrawTempBack.setOnClickListener(v -> onBackPressed());

        mDataBinding.rvTemplateList.setLayoutManager(new GridLayoutManager(mContext, 3));
        tempAdapter = new DrawTempAdapter();
        mDataBinding.rvTemplateList.setAdapter(tempAdapter);
        tempAdapter.setOnItemClickListener(this);
    }

    @Override
    protected void onItemClickCallback(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
        gotoDraw(tempAdapter.getItem(position).getImg());
    }

    @Override
    protected void initData() {
        List<MyDrawTempBean> listTemp = new ArrayList<>();
        listTemp.add(new MyDrawTempBean(R.drawable.mb_1a, R.drawable.mb_1));
        listTemp.add(new MyDrawTempBean(R.drawable.mb_2a, R.drawable.mb_2));
        listTemp.add(new MyDrawTempBean(R.drawable.mb_3a, R.drawable.mb_3));
        listTemp.add(new MyDrawTempBean(R.drawable.mb_4a, R.drawable.mb_4));
        listTemp.add(new MyDrawTempBean(R.drawable.mb_5a, R.drawable.mb_5));
        listTemp.add(new MyDrawTempBean(R.drawable.mb_6a, R.drawable.mb_6));
        listTemp.add(new MyDrawTempBean(R.drawable.mb_7a, R.drawable.mb_7));
        listTemp.add(new MyDrawTempBean(R.drawable.mb_8a, R.drawable.mb_8));
        listTemp.add(new MyDrawTempBean(R.drawable.mb_9a, R.drawable.mb_9));
        listTemp.add(new MyDrawTempBean(R.drawable.mb_10a, R.drawable.mb_10));
        listTemp.add(new MyDrawTempBean(R.drawable.mb_11a, R.drawable.mb_11));
        listTemp.add(new MyDrawTempBean(R.drawable.mb_12a, R.drawable.mb_12));
        listTemp.add(new MyDrawTempBean(R.drawable.mb_13a, R.drawable.mb_13));
        listTemp.add(new MyDrawTempBean(R.drawable.mb_14a, R.drawable.mb_14));
        listTemp.add(new MyDrawTempBean(R.drawable.mb_15a, R.drawable.mb_15));
        listTemp.add(new MyDrawTempBean(R.drawable.mb_16a, R.drawable.mb_16));
        listTemp.add(new MyDrawTempBean(R.drawable.mb_17a, R.drawable.mb_17));
        listTemp.add(new MyDrawTempBean(R.drawable.mb_18a, R.drawable.mb_18));
        tempAdapter.setList(listTemp);
    }

    //去到绘画界面
    private void gotoDraw(int img) {
        DrawActivity.kind = 1;
        DrawActivity.selImg = img;
        startActivity(DrawActivity.class);
    }

}